# The MIT License (MIT)
#
# Copyright (c) 2015-2017 Simon Ninon <simon.ninon@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

###
# compilation options
###
if(NOT WIN32)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-unused-variable")
endif(NOT WIN32)


###
# includes
###
include_directories(${CPP_REDIS_INCLUDES})


###
# libraries
###
link_directories(${DEPS_LIBRARIES})

set(EXAMPLES cpp_redis_client
              cpp_redis_consumer
              cpp_redis_future_client
              cpp_redis_subscriber
              cpp_redis_logger
              cpp_redis_kill
              cpp_redis_streams_client
              cpp_redis_high_availability_client
              cpp_redis_multi_exec
    )

foreach(EXAMPLE IN ITEMS ${EXAMPLES})
  ###
  # executable
  ###
  add_executable(${EXAMPLE} ${EXAMPLE}.cpp)
  target_link_libraries(${EXAMPLE} cpp_redis)

  ###
  # link libs
  ###
  if(WIN32)
    target_link_libraries(${EXAMPLE} ws2_32)
  else()
    target_link_libraries(${EXAMPLE} pthread)
  endif(WIN32)
endforeach(EXAMPLE)
